namespace = IQINS
character_event = {
	id = IQINS.002
	
	hide_window = yes # Only fires for unplayable landless characters
	
	is_triggered_only = yes
	
	trigger = {
		is_ruler = no
		NOT = { any_spouse = { is_ruler = yes } }
		
		any_claim = {
			has_holder = yes
			holder_scope = {
				independent = yes # Only do this vs independent rulers
			}
		}
	}
	
	immediate = {
		
		wealth = 500
		prestige = 100
		piety = 100
		clr_character_flag = do_not_disturb
		any_claim = {
			limit = {
				has_title_flag = iqtaprimarytitle
				#holder_scope = {
				#	has_character_flag = iqta_destabilized
				#}
				#has_holder = yes
				#OR = {
				#	tier = KING
				#	tier = EMPEROR
				#}
			}
		save_event_target_as = the_claim
		holder_scope = {
			save_event_target_as = the_liege
			capital_scope = {
				ROOT = {
					set_defacto_liege = ROOT
					create_title = {
						tier = DUKE
						landless = yes
						temporary = yes
						adventurer = yes
						culture = ROOT
						name = "CLAIMANT_ADVENTURE"
						holder = ROOT
					}
					add_trait = adventurer
					
					event_target:the_claim = {
						#limit = {
						#	has_holder = yes
						#	OR = {
						#		tier = KING
						#		tier = EMPEROR
						#	}
						#}
						event_target:the_liege = {
							random_realm_province = {
								ROOT = {
								set_character_flag = claimant_adventurer
								
								#BASE ARMY
										spawn_unit = {
											province = PREV
											home = PREV
											owner = ROOT
											#leader = THIS
											match_character = event_target:the_liege
											match_mult = 0.5
											match_min = 300
											match_max = 1000000
											attrition = 0.25
											earmark = claimant_adventure
											disband_on_peace = yes
											reinforces = yes
										}
										
								#75 to 125
										random_list = {
											20 = {
												spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.25
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = yes
												}
											}
											20 = {
												spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.375
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = yes
												}
											}
											20 = {
												spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.55
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = yes
												}
											}
											20 = {
												spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.625
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = yes
												}
											}
											20 = {
												spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.75
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = yes
												}
											}
										}
				#AMBITIOUS
										if = {
										limit = {
											trait = ambitious
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.50
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = yes
												}
										}
					#EDUCATION
										if = {
										limit = {
											trait = skilled_tactician
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.15
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
										if = {
										limit = {
											trait = brilliant_strategist
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.25
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
										if = {
										limit = {
											trait = charismatic_negotiator
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.10
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
										if = {
										limit = {
											trait = grey_eminence
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.15
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
										if = {
										limit = {
											trait = fortune_builder
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.10
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
										if = {
										limit = {
											trait = midas_touched
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.15
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
										if = {
										limit = {
											trait = intricate_webweaver
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.10
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
										if = {
										limit = {
											trait = elusive_shadow
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.15
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
				#REGULAR TRAITS
										if = {
										limit = {
											trait = diligent
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.15
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
										if = {
										limit = {
											trait = sayyid
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.15
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
										if = {
										limit = {
											trait = berserker
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.50
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
									if = {
										limit = {
											trait = brave
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.05
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
			#LIFESTYLE
									if = {
										limit = {
											trait = duelist
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.10
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
										if = {
										limit = {
											trait = schemer
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.10
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
										if = {
										limit = {
											trait = hunter
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.10
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
										if = {
										limit = {
											trait = impaler
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.10
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
										if = {
										limit = {
											trait = strategist
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.20
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
										if = {
										limit = {
											OR = {
											trait = seducer
											trait = seductress
											}
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.05
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
				#SMART
										if = {
										limit = {
											trait = shrewd
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.15
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
										if = {
										limit = {
											trait = genius
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.25
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
										if = {
										limit = {
											trait = quick
										}
										spawn_unit = {
												province = PREV
												home = PREV
												owner = ROOT
												#leader = THIS
												match_character = event_target:the_liege
												match_mult = 0.15
												match_min = 300
												match_max = 1000000
												attrition = 0.25
												earmark = claimant_adventure
												disband_on_peace = yes
												reinforces = no
												}
										}
								}
							}
						}
						}
					}
				}
			}
			}
		# I no longer have a valid claim on the target
		if = {
			limit = {
				NOT = { has_character_flag = claimant_adventurer }
			}
			break = yes
		}
		
		# Create some decent commander characters
		create_random_soldier = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 30
		}
		create_random_soldier = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 25
		}
		create_random_soldier = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 33
		}
		create_random_soldier = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 29
		}
		
		# Create a fleet, just to be sure
		spawn_fleet = {
			province = closest # closest sea zone
			owner = ROOT
			disband_on_peace = yes
			troops =
			{
				galleys = { 150 150 }
			}
			earmark = claimant_adventure
		}
		
		event_target:the_claim = {
			#limit = {
			#	has_holder = yes
			#	OR = {
			#		tier = KING
			#		tier = EMPEROR
			#	}
			#	}
			
			ROOT = {
				unsafe_war = {
					target = event_target:the_liege
					casus_belli = iqtins_claim
					thirdparty_title = PREV
				}
			}
		}
	}
	after = {

	}
	option = {
		name = OK
		#event_target:the_claim = {
		#	clr_title_flag = iqtaprimarytitle
		#}
		clear_event_target = the_liege
		clear_event_target = the_claim
	}
}